<template>
  <div v-loading="loading">
    <DkDouyinCurrentContainer :row="versions['current']" @update="onGetDouyinVersionsByAppId()" />
    <DkDouyinAuditContainer :row="versions.audit" class="mt-5" @update="onGetDouyinVersionsByAppId()" />
    <DkDouyinLatestContainer :row="versions['latest']" class="mt-5" @update="onGetDouyinVersionsByAppId()" />
    <DkDouyinUploadContainer class="mt-5" @update="onGetDouyinVersionsByAppId()" />
  </div>
</template>

<script setup>
import { ref, computed, inject, onMounted } from 'vue'
import { getDouyinVersionsByAppId } from '@/api/platform/app/douyin_open'
import DkDouyinAuditContainer from './DkDouyinAuditContainer.vue'
import DkDouyinLatestContainer from './DkDouyinLatestContainer.vue'
import DkDouyinUploadContainer from './DkDouyinUploadContainer.vue'
import DkDouyinCurrentContainer from './DkDouyinCurrentContainer.vue'

defineOptions({
  name: 'DkDouyinUploadOpen'
})

const loading = ref(true)
const versions = ref({})
const defaultApp = inject('defaultApp')

const platformAppId = computed(() => {
  return app.appid
})

const onGetDouyinVersionsByAppId = () => {
  loading.value = true
  console.log('platformAppId', defaultApp.value.id)

  getDouyinVersionsByAppId(defaultApp.value.id)
    .then((res) => {
      versions.value = res.data
      loading.value = false
    })
    .catch(() => {
      loading.value = false
    })
}

onMounted(() => {
  onGetDouyinVersionsByAppId()
})
</script>

<style scoped lang="scss"></style>
